package org.bmi.gwt.examples.serverevent.shared;

import org.bmi.gwt.mi.shared.MiObject;

import com.google.gwt.dom.client.Document;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class MyTestObject implements MiObject
{
	private String str;

	public MyTestObject(String str)
	{
		this.str = str;
	}

	/*
	 * The method of this object just processes a string returning another
	 * string made using provided constructor string and its argument. Since on
	 * the server, a handler is active we expect that what we see will depends
	 * on the string provided on server wrapping the constructor.
	 */

	public void process(String str)
	{
		RootPanel rootPanel = RootPanel.get();
		Element body = rootPanel.getElement();

		String text = this.str + " --> " + str;

		body.appendChild(Document.get().createBRElement());
		body.appendChild(Document.get().createTextNode(text));

	}
}
